<link rel="stylesheet" href='<?php echo $this->baseUrl() ?>/public/css/home.css'/>
<h1>
    Sliding Images
</h1>
<div class='wrap-content'>
    <label>
        Preview Image
    </label>
    <div class='content'>
        <?php if ($this->images->count() == 0): ?>
            <div class='inform'>
                There's no sliding images
            </div>
        <?php else: ?>
            <?php $edit_image_url = $this->url(array('action' => 'editimage')); ?>
            <?php foreach ($this->images as $image): ?>
                <div class='wrap-preview-image'>
                    <form action='<?php echo $edit_image_url ?>' method='POST'>                        
                        <img src='<?php echo UPLOAD_URL . $image->file?>'/>
                        <textarea id='caption_<?php echo $image->id?>' name='caption'>
                            <?php echo $image->caption ?>
                        </textarea>
                        <input type='hidden' name='imgid' value='<?php echo $image->id ?>'/>
                        <input type='submit' value='Save' class='submit-button'/>
                    </form>
                </div>
                <?php $delete_image_url = $this->url(array("action" => "deleteimage", "imgid" => $image->id)) ?>
                <a href='<?php echo $delete_image_url ?>' class='delete-button' title='delete this image'>X</a>
            <?php endforeach; ?>               
        <?php endif;?>
    </div> 
</div>
<div class='wrap-content'>
    <label>
        New Image
    </label>
    <div class='content'>
        <?php 
            $url = $this->url(array(
                'module'     => 'admin',
                'controller' => 'index',
                'action'     => 'newimage'
            ));
        ?>
        <form action='<?php echo $url ?>' method='POST' enctype="multipart/form-data">
            <div class='wrap-input'>
                <input type='file' name='file'/>
            </div>
            <div class='wrap-input'>
                <textarea id='new_caption' name='caption'></textarea>
            </div>
            <div class='wrap-input'>
                <input type='submit' class='submit-button' />
            </div>
        </form>
    </div> 
</div>                
<script src="<?php echo $this->baseUrl() ?>/public/js/tinymce/tinymce.min.js"></script>
<script type="text/javascript">
    tinymce.init({
        selector: "textarea",
        toolbar: "insertfile undo redo | styleselect | bold italic forecolor fontsizeselect fontselect | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image"
    });
</script>
